package com.aggron.service.impl;

import com.aggron.dao.SysUserMapper;
import com.aggron.entity.SysRoleUser;
import com.aggron.dao.SysRoleUserMapper;
import com.aggron.entity.SysUser;
import com.aggron.service.ISysRoleUserService;
import com.aggron.util.CollectionsUtil;
import com.baomidou.mybatisplus.service.impl.ServiceImpl;
import com.google.common.collect.Lists;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * <p>
 *  服务实现类
 * </p>
 *
 * @author liuhuan
 * @since 2018-06-02
 */
@Service
public class SysRoleUserServiceImpl extends ServiceImpl<SysRoleUserMapper, SysRoleUser> implements ISysRoleUserService {

    @Autowired
    private SysRoleUserMapper sysRoleUserMapper;

    @Autowired
    private SysUserMapper sysUserMapper;

    @Override
    public List<SysUser> getUserIdByRoleId(Integer roleId) {
        List<Integer> userIdList= sysRoleUserMapper.getUserIdByRoleId(roleId);
        if(CollectionsUtil.isEmpty(userIdList)){
            return Lists.newArrayList();
        }

        return sysUserMapper.getUserListByUserIdList(userIdList);
    }
}
